package components.game
{
	import SEApp.se_util;
	
	import UIFree.controls.uif_hscrollArea;
	import UIFree.uif_component;
	import UIFree.uif_ecomponent;
	
	import flash.geom.Rectangle;

	public class clt_comments extends uif_ecomponent {
		private var _filterList		: Array;
		private var _previewArea	: uif_hscrollArea;
		
		public static const CONTENTTYPE_NEW	: int = -1;
		public static const CONTENTTYPE_COM	: int = 1;
		public static const CONTENTTYPE_MSG	: int = 2;
		public static const NEWCOMMENT		: String = 'NEWCOMMENT';
		
		public function clt_comments(parent:uif_component, ax:int=0, ay:int=0, awidth:int=0, aheight:int=0, styleClass:String='') {
			super(parent, ax, ay, awidth, aheight, styleClass);
			createComponents();
		}
		
		protected function createComponents(): void {
			_previewArea = se_util.createComponent(this, uif_hscrollArea, 'items') as uif_hscrollArea;
		}
		
		public function get listArea(): uif_hscrollArea {
			return _previewArea;
		}
	
		public function set list(a_list: Array): void {
			var inner: Rectangle = _previewArea.displayRect;
			var itemToCount: int = 3;
			var itemWidth: Number = inner.width / itemToCount;
			_filterList = a_list;
			
			_previewArea.assignList(_filterList, itemWidth, createElem);
		}
		
		protected function createElem(_scroll: uif_component, inner: Rectangle, index: int): clt_commentItem {
			return new clt_commentItem(index, _scroll, inner.x, inner.y, inner.width, inner.height, _filterList[index], style.unselect);
		}
		
		public function clear(): void {
			_previewArea.scrollArea.removeChilds();
		}
	}
}